
#ifndef _TTG_EXTRAS_LEXER_
#define _TTG_EXTRAS_LEXER_
#include "Common/Definitions.h"

#include "CharBuffer.h"
#include "Common/Errors.h"

namespace ttg_internal
{
	class Lexer
	{
		private:
			static const int STATE_PARSING_SECTION = 1;
			static const int STATE_PARSING_TAG = 2;
			int state;
			int type;
			CharBuffer tag;
			CharBuffer value;
			CharBuffer extag;
			CharBuffer attr;
			FILE *source;
			int spendSplitters();
			int readNext_Section();
			int readNext_Tag();
		public:
			static const int XML_ERROR = 0;
			static const int XML_TAG_OPEN = 1;
			static const int XML_TAG_CLOSE = 2;
			static const int XML_TAG_COMMENT = 3;
			static const int XML_TAG_INF = 4;
			static const int XML_END_OF_FILE = 5;
			Lexer(FILE *source);
			//Reading
			int readNext();
			int getType() const;
			const char *showTag() const;
			const char *showValue() const;
			//Writing
			void addTag(int tag, const char *name);
			void addValue(const char *val);
			FILE *getSource();
			~Lexer();
	};
}

#endif
